 {include file="public/header" /}
 {load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
{load href="__PLUGINS__layui/layui.js"}
{load href="__PLUGINS__layui/css/layui.css"}
<style type="text/css">
#des,#des input{ width: 40px;text-align:center;}
#id{ width: 78px; }
.bs-checkbox{ width: 36px; height: 40px }
.fixed-table-toolbar .columns,.fixed-table-toolbar .search{margin-left:0px; margin-top: 0px }
#title span{ float: right; margin-left: 3.333px;}
</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                     <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">id</th>
                                    <th>栏目分类</th>
                                    <th>文章标题</th>
                                    <th>访问次数</th>
                                    <th>更新时间</th>
                                    <th>状态</th>
                                    <th>管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                               <!--  {php}$hide=array('0'=>'<font color="#f00">隐藏</font>','1'=>'<font color="#1ab394">通过</font>','2'=>'审核','3'=>'<font color="#f00">拒绝</font>','4'=>'重新编辑');{/php} -->
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                   <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td id="id">{$v.id}</td>
                                    <td><a href="{:url('article/index',['typeid'=>$v['typeid']])}">{:_typeid($v['typeid'])}</a></td>
                                    <td id="title">
                                    <a onclick="watch({$v.id})">{:_substr($v.title)}</a>
                                    {notempty name="v.description"} 
                                    {:_substr($v.description)}
                                    {/notempty}
                                    {notempty name="v.url"} 
                                    
                                        <span class="label label-danger">跳</span>
                                    {/notempty}
                                    {notempty name="v.flags"}
                                        <span class="label label-primary">{:_flags($v['flags'])}</span>
                                    {/notempty}
                                    {notempty name="v.image"}
                                        <span class="label label-primary">图</span>
                                    {/notempty}
                                    </td>
                                    <td>{$v.click}</td>
                                    <td> 
                                        <span {php}if(date('Ymd')==date('Ymd',$v['update_time']))echo 'style="color: #ed5565"';{/php}>{$v.update_time|date='Y-m-d H:i:s',###}</span>
                                    </td>
                                    <td id="hide{$v.id}">{$hide[$v['hide']]}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li>
                                                    <a onclick="hides({$v.id},0)">
                                                        <font color="#f00">隐藏</font></a>
                                                </li>
                                                <li>
                                                    <a onclick="hides({$v.id},1)">
                                                        <font color="#1ab394">通过</font></a>
                                                </li>

                                                <li>
                                                    <a onclick="hides({$v.id},2)">审核</a>
                                                </li>
                                                <li>
                                                     <a onclick="x_admin_show('重新编辑','{:url('article/reviewadd',['id'=>$v['id'],'url'=>-1,'hide'=>4])}')">重新编辑</a>
                                                </li>
                                                <li>
                                                    <a onclick="x_admin_show('拒绝操作','{:url('article/reviewadd',['id'=>$v['id'],'url'=>-1,'hide'=>3])}')">拒绝操作</a>
                                                    <!-- <a onclick="hides({$v.id},3)">
                                                        <font color="#f00">拒绝</font></a> -->
                                                </li>
                                                <!-- {php}$vak=0;{/php}
                                                {volist name='hide' id='va'}
                                                <li><a onclick="hides({$v['id']},{$vak})">{$va}</a></li>
                                                {php}$vak+=1;{/php}
                                                {/volist}  -->
                                                <li class="divider"></li>
                                                <li><a onclick="add('{:url('add',['id'=>$v['id'],'mychannel'=>$v['mychannel'],'url'=>-1])}')">修改</a>
                                                </li>
                                                <li><a onclick="del({$v.id})">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
         
            <div class="row row-lg">
                <div class="col-sm-6">
                      <div  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(3)">
                        批量拒绝
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(2)">
                        批量审核
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(0)">
                        批量隐藏
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                   
                </div>
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){

    
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});
function hides(id,type){
    $.ajax({
        type: 'post',
        url: '{:url("hide")}',
        data: {id:id,type:type},
        dataType: 'json',
        success:function(ret){
            layer.msg('设置成功')
            $('#hide'+id).html(ret);
        },
        error:function(err){
           alert(JSON.stringify(err))
        }
    });
}
function del(id){
    swal_del(id,"{:url('del')}")
}
 
function alla(types){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
   //console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('article/all')}?type='+types,all,'json',function(ret){
        
        if(ret){
            var text
            switch(types)
            {
            case 0:
              text='<font color="#f00">隐藏</font>';
              break;
            case 1:
              text='<font color="#1ab394">通过</font>'
              break;
            case 2:
              text ='审核';
              break;
            case 3:
              text ='<font color="#f00">拒绝</font>';
              break;
          case 4:
          text ='<font color="#f00">重新编辑</font>';
          break;
            }

            for(var i=0;i<alls.length;i++){
                if(types=='del'){
                    $('#id'+alls[i]['value']).remove();
                }else{
                    $('#hide'+alls[i]['value']).html(text);
                }
            }
             
            swal_msg('操作成功')
        }
    })
}
function watch(id) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['100%', '100%'],
          type: 2, 
          content: '{:url('article/watch')}?id='+id // //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
        }); 

     
    });
} 
function x_admin_show(title,url,w,h)
{
    if (title == null || title == '') {
        title=false;
    };
    if (url == null || url == '') {
        url="404.html";
    };
    if (w == null || w == '') {
        w=($(window).width()*0.9);
    };
    if (h == null || h == '') {
        h=($(window).height() - 50);
    };
    layer.open({
        type: 2,
        area: [w+'px', h +'px'],
        fix: false, //不固定
        maxmin: true,
        shadeClose: true,
        shade:0.4,
        title: title,
        content: url,
        end: function (){
            window.location.reload();
        }
        
    });
}
</script>
 